```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tomcat 日志配置指南 - 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #222;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
        }
        .code-block {
            background-color: #2d3748;
            color: #f7fafc;
            border-radius: 0.5rem;
            overflow-x: auto;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .hover-scale:hover {
            transform: scale(1.02);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6 sm:px-12 lg:px-24">
        <div class="max-w-4xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6">Tomcat 日志配置完全指南</h1>
            <p class="text-xl md:text-2xl opacity-90 mb-8">掌握访问日志与错误日志的配置技巧，打造高效可靠的服务器监控体系</p>
            <div class="flex justify-center space-x-4">
                <a href="#access-log" class="px-6 py-3 bg-white text-indigo-700 font-semibold rounded-lg hover:bg-opacity-90 transition-all duration-300 shadow-lg">
                    <i class="fas fa-file-alt mr-2"></i>访问日志配置
                </a>
                <a href="#error-log" class="px-6 py-3 bg-indigo-800 text-white font-semibold rounded-lg hover:bg-indigo-700 transition-all duration-300 shadow-lg">
                    <i class="fas fa-exclamation-triangle mr-2"></i>错误日志配置
                </a>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        <!-- Introduction -->
        <div class="bg-white rounded-xl shadow-md p-8 mb-12">
            <div class="flex items-center mb-6">
                <div class="bg-indigo-100 p-3 rounded-full mr-4">
                    <i class="fas fa-info-circle text-indigo-600 text-2xl"></i>
                </div>
                <h2 class="text-2xl font-semibold">日志配置的重要性</h2>
            </div>
            <p class="text-lg text-gray-700 mb-6">
                在 Tomcat 中，访问日志和错误日志的配置是非常重要的，它们可以帮助开发者和系统管理员监控服务器的运行状态、分析用户的访问行为、排查问题等。Tomcat 提供了灵活的日志配置选项，支持多种日志滚动和清理策略。
            </p>
            <div class="mt-6" id="mermaid-diagram"></div>
        </div>

        <!-- Access Log Section -->
        <section id="access-log" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="bg-blue-100 p-3 rounded-full mr-4">
                    <i class="fas fa-file-alt text-blue-600 text-2xl"></i>
                </div>
                <h2 class="text-3xl font-semibold">1. 配置访问日志</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 card-hover transition-all duration-300">
                <div class="bg-blue-600 px-6 py-4 flex items-center">
                    <i class="fas fa-lightbulb text-white mr-3"></i>
                    <h3 class="text-xl font-semibold text-white">访问日志概述</h3>
                </div>
                <div class="p-6">
                    <p class="text-gray-700 mb-6">访问日志记录了客户端对服务器的每一个请求，这些日志通常用于流量分析、安全监控等。Tomcat 使用 <code class="bg-blue-100 text-blue-800 px-2 py-1 rounded">AccessLogValve</code> 组件来管理访问日志。</p>
                    
                    <div class="mb-8">
                        <h4 class="text-xl font-semibold mb-4 text-gray-800 flex items-center">
                            <i class="fas fa-code mr-2 text-blue-600"></i>配置示例
                        </h4>
                        <div class="code-block p-4 rounded-lg mb-4">
                            <pre class="text-sm"><code>&lt;Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"&gt;

    &lt;!-- 配置访问日志 --&gt;
    &lt;Valve className="org.apache.catalina.valves.AccessLogValve" 
           directory="logs"           &lt;!-- 日志文件存储目录 --&gt;
           prefix="localhost_access_log."  &lt;!-- 日志文件名前缀 --&gt;
           suffix=".txt"              &lt;!-- 日志文件名后缀 --&gt;
           pattern="%h %l %u %t &amp;quot;%r&amp;quot; %s %b"  &lt;!-- 日志格式 --&gt;
           fileDateFormat=".yyyy-MM-dd" &lt;!-- 日志文件滚动格式 --&gt;
           rotatable="true"            &lt;!-- 是否启用日志滚动 --&gt;
           renameOnRotate="true"       &lt;!-- 滚动后是否重命名文件 --&gt;
           maxDays="90"                &lt;!-- 保留日志的天数 --&gt;
           /&gt;
&lt;/Host&gt;</code></pre>
                        </div>
                    </div>

                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="bg-blue-50 p-6 rounded-lg hover-scale transition-all duration-200">
                            <h4 class="text-lg font-semibold mb-3 text-blue-800 flex items-center">
                                <i class="fas fa-list-ul mr-2"></i>参数说明
                            </h4>
                            <ul class="space-y-2 text-gray-700">
                                <li><strong>directory</strong>：指定日志文件的存储目录</li>
                                <li><strong>prefix</strong>：日志文件名前缀</li>
                                <li><strong>suffix</strong>：日志文件名后缀</li>
                                <li><strong>pattern</strong>：日志输出格式</li>
                                <li><strong>fileDateFormat</strong>：日志文件滚动格式</li>
                                <li><strong>rotatable</strong>：是否启用日志滚动</li>
                                <li><strong>renameOnRotate</strong>：滚动后是否重命名</li>
                                <li><strong>maxDays</strong>：保留日志的天数</li>
                            </ul>
                        </div>
                        
                        <div class="bg-blue-50 p-6 rounded-lg hover-scale transition-all duration-200">
                            <h4 class="text-lg font-semibold mb-3 text-blue-800 flex items-center">
                                <i class="fas fa-percentage mr-2"></i>日志格式符
                            </h4>
                            <ul class="space-y-2 text-gray-700">
                                <li><strong>%h</strong>：远程主机名或IP地址</li>
                                <li><strong>%l</strong>：远程登录名（通常显示为"-"）</li>
                                <li><strong>%u</strong>：已通过身份验证的远程用户</li>
                                <li><strong>%t</strong>：请求的时间</li>
                                <li><strong>%r</strong>：请求的第一行</li>
                                <li><strong>%s</strong>：响应状态码</li>
                                <li><strong>%b</strong>：响应的字节数（不包括HTTP头）</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Error Log Section -->
        <section id="error-log" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="bg-red-100 p-3 rounded-full mr-4">
                    <i class="fas fa-exclamation-triangle text-red-600 text-2xl"></i>
                </div>
                <h2 class="text-3xl font-semibold">2. 配置错误日志</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 card-hover transition-all duration-300">
                <div class="bg-red-600 px-6 py-4 flex items-center">
                    <i class="fas fa-bug text-white mr-3"></i>
                    <h3 class="text-xl font-semibold text-white">错误日志概述</h3>
                </div>
                <div class="p-6">
                    <p class="text-gray-700 mb-6">错误日志记录了服务器运行过程中发生的异常或错误。Tomcat 默认将错误日志输出到 <code class="bg-red-100 text-red-800 px-2 py-1 rounded">logs/catalina.out</code> 和 <code class="bg-red-100 text-red-800 px-2 py-1 rounded">logs/host-manager.[date].log</code> 中。</p>
                    
                    <div class="mb-8">
                        <h4 class="text-xl font-semibold mb-4 text-gray-800 flex items-center">
                            <i class="fas fa-cog mr-2 text-red-600"></i>配置示例
                        </h4>
                        <div class="code-block p-4 rounded-lg mb-4">
                            <pre class="text-sm"><code># 配置 catalina 日志文件
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
1catalina.org.apache.juli.FileHandler.suffix = .log
1catalina.org.apache.juli.FileHandler.limit = 10000000
1catalina.org.apache.juli.FileHandler.count = 10
1catalina.org.apache.juli.FileHandler.formatter = org.apache.juli.VerbatimFormatter

# 配置控制台日志
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter</code></pre>
                        </div>
                    </div>

                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="bg-red-50 p-6 rounded-lg hover-scale transition-all duration-200">
                            <h4 class="text-lg font-semibold mb-3 text-red-800 flex items-center">
                                <i class="fas fa-list-ul mr-2"></i>参数说明
                            </h4>
                            <ul class="space-y-2 text-gray-700">
                                <li><strong>directory</strong>：日志文件存储目录</li>
                                <li><strong>prefix</strong>：日志文件前缀</li>
                                <li><strong>suffix</strong>：日志文件后缀</li>
                                <li><strong>limit</strong>：单个日志文件最大大小（字节）</li>
                                <li><strong>count</strong>：日志文件最大数量</li>
                                <li><strong>formatter</strong>：日志格式化器</li>
                            </ul>
                        </div>
                        
                        <div class="bg-red-50 p-6 rounded-lg hover-scale transition-all duration-200">
                            <h4 class="text-lg font-semibold mb-3 text-red-800 flex items-center">
                                <i class="fas fa-signal mr-2"></i>日志级别
                            </h4>
                            <ul class="space-y-2 text-gray-700">
                                <li><strong>SEVERE</strong>：严重错误</li>
                                <li><strong>WARNING</strong>：警告信息</li>
                                <li><strong>INFO</strong>：一般信息</li>
                                <li><strong>CONFIG</strong>：配置信息</li>
                                <li><strong>FINE</strong>：调试信息</li>
                                <li><strong>FINER</strong>：更详细的调试信息</li>
                                <li><strong>FINEST</strong>：最详细的调试信息</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Log Rotation Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="bg-purple-100 p-3 rounded-full mr-4">
                    <i class="fas fa-sync-alt text-purple-600 text-2xl"></i>
                </div>
                <h2 class="text-3xl font-semibold">3. 日志文件的滚动和清理策略</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md p-8 card-hover transition-all duration-300">
                    <h3 class="text-2xl font-semibold mb-6 text-purple-800 flex items-center">
                        <i class="fas fa-calendar-alt mr-3"></i>滚动策略
                    </h3>
                    <div class="space-y-6">
                        <div>
                            <h4 class="text-lg font-semibold mb-2 text-gray-800">1. 按日期滚动</h4>
                            <p class="text-gray-700">通常用于访问日志，通过配置 <code class="bg-purple-100 text-purple-800 px-2 py-1 rounded">fileDateFormat</code> 按天或按小时滚动日志文件。例如，<code class="bg-purple-100 text-purple-800 px-2 py-1 rounded">fileDateFormat=".yyyy-MM-dd"</code> 会按天生成日志文件。</p>
                        </div>
                        
                        <div>
                            <h4 class="text-lg font-semibold mb-2 text-gray-800">2. 按大小滚动</h4>
                            <p class="text-gray-700">通常用于错误日志，通过设置 <code class="bg-purple-100 text-purple-800 px-2 py-1 rounded">limit</code> 参数控制每个日志文件的最大大小。超过此大小时，Tomcat 会创建一个新的日志文件。</p>
                        </div>
                        
                        <div>
                            <h4 class="text-lg font-semibold mb-2 text-gray-800">3. 滚动后重命名</h4>
                            <p class="text-gray-700">配置 <code class="bg-purple-100 text-purple-800 px-2 py-1 rounded">renameOnRotate="true"</code>，在日志文件滚动后重命名旧的日志文件，而不是简单的删除或覆盖。</p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-8 card-hover transition-all duration-300">
                    <h3 class="text-2xl font-semibold mb-6 text-purple-800 flex items-center">
                        <i class="fas fa-trash-alt mr-3"></i>清理策略
                    </h3>
                    <div class="space-y-6">
                        <div>
                            <h4 class="text-lg font-semibold mb-2 text-gray-800">1. maxDays 参数</h4>
                            <p class="text-gray-700">通过设置 <code class="bg-purple-100 text-purple-800 px-2 py-1 rounded">maxDays</code> 参数，Tomcat 可以自动删除超过指定天数的日志文件，防止日志占用过多的磁盘空间。</p>
                        </div>
                        
                        <div>
                            <h4 class="text-lg font-semibold mb-2 text-gray-800">2. 日志轮转配置</h4>
                            <p class="text-gray-700">通过设置 <code class="bg-purple-100 text-purple-800 px-2 py-1 rounded">count</code> 参数，限制日志文件的最大数量。超过数量的日志文件会被删除。</p>
                        </div>
                        
                        <div>
                            <h4 class="text-lg font-semibold mb-2 text-gray-800">3. 外部工具或脚本清理</h4>
                            <p class="text-gray-700">可以使用操作系统的计划任务（如 Linux 的 <code class="bg-purple-100 text-purple-800 px-2 py-1 rounded">cron</code>）或脚本定期清理过期的日志文件。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Best Practices -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="bg-green-100 p-3 rounded-full mr-4">
                    <i class="fas fa-check-circle text-green-600 text-2xl"></i>
                </div>
                <h2 class="text-3xl font-semibold">4. 最佳实践</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md p-8 card-hover transition-all duration-300">
                <div class="grid md:grid-cols-2 gap-8">
                    <div class="flex">
                        <div class="bg-green-100 p-3 h-12 w-12 rounded-full flex-shrink-0 flex items-center justify-center mr-4 mt-1">
                            <i class="fas fa-check text-green-600"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-3 text-gray-800">启用访问日志和错误日志</h3>
                            <p class="text-gray-700">确保所有生产环境中的 Tomcat 实例都启用了访问日志和错误日志，以便在出现问题时可以快速诊断。</p>
                        </div>
                    </div>
                    
                    <div class="flex">
                        <div class="bg-green-100 p-3 h-12 w-12 rounded-full flex-shrink-0 flex items-center justify-center mr-4 mt-1">
                            <i class="fas fa-check text-green-600"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-3 text-gray-800">设置合理的滚动和清理策略</h3>
                            <p class="text-gray-700">根据服务器负载和应用需求，设置合适的日志滚动和清理策略，避免日志文件占用过多磁盘空间。</p>
                        </div>
                    </div>
                    
                    <div class="flex">
                        <div class="bg-green-100 p-3 h-12 w-12 rounded-full flex-shrink-0 flex items-center justify-center mr-4 mt-1">
                            <i class="fas fa-check text-green-600"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-3 text-gray-800">监控日志文件大小和数量</h3>
                            <p class="text-gray-700">使用监控工具或脚本定期检查日志文件大小和数量，防止磁盘空间被日志文件耗尽。</p>
                        </div>
                    </div>
                    
                    <div class="flex">
                        <div class="bg-green-100 p-3 h-12 w-12 rounded-full flex-shrink-0 flex items-center justify-center mr-4 mt-1">
                            <i class="fas fa-check text-green-600"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-3 text-gray-800">日志分级管理</h3>
                            <p class="text-gray-700">根据日志的重要性和使用场景，配置不同的日志级别和输出目标，提高日志分析的效率。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-6">
        <div class="max-w-6xl mx-auto">
            <div class="text-center">
                <h3 class="text-xl font-semibold text-white mb-4">技术小馆</h3>
                <a href="http://www.yuque.com/jtostring" class="text-indigo-300 hover:text-white transition-colors duration-200">
                    <i class="fas fa-external-link-alt mr-2"></i>http://www.yuque.com/jtostring
                </a>
                <div class="mt-6 flex justify-center space-x-4">
                    <a href="#" class="text-gray-400 hover:text-white transition-colors duration-200">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition-colors duration-200">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition-colors duration-200">
                        <i class="fab fa-weixin text-xl"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        document.addEventListener('DOMContentLoaded', function() {
            const diagramDefinition = `
                graph TD
                    A[Tomcat 日志配置] --> B[访问日志]
                    A --> C[错误日志]
                    B --> D[AccessLogValve]
                    B --> E[server.xml]
                    B --> F[日志格式配置]
                    C --> G[logging.properties]
                    C --> H[日志级别设置]
                    A --> I[日志滚动策略]
                    I --> J[按日期滚动]
                    I --> K[按大小滚动]
                    I --> L[滚动后重命名]
                    A --> M[日志清理策略]
                    M --> N[maxDays 参数]
                    M --> O[count 参数]
                    M --> P[外部脚本清理]
            `;
            
            document.getElementById('mermaid-diagram').innerHTML = `<div class="mermaid">${diagramDefinition}</div>`;
        });
    </script>
</body>
</html>
```